public class Course {
    // 属性（成员变量）
    private String courseId;
    private String courseName;
    private int credit;
    private String teacher;
    private String time;
    private String classroom;
    private int capacity;
    private int enrolledCount;

    // 构造函数
    private Course() {
        // 默认构造函数
    }

    public Course(String courseId, String courseName, int credit, String teacher,
                  String time, String classroom, int capacity) {
        this.courseId = courseId;
        this.courseName = courseName;
        this.credit = credit;
        this.teacher = teacher;
        this.time = time;
        this.classroom = classroom;
        this.capacity = capacity;
        this.enrolledCount = 0; // 初始选课人数为0
    }

    public static Course createCourse() {
        return new Course();
    }

    // Getter方法
    public String getCourseId() {
        return courseId;
    }

    public String getCourseName() {
        return courseName;
    }

    public int getCredit() {
        return credit;
    }

    public String getTeacher() {
        return teacher;
    }

    public String getTime() {
        return time;
    }

    public String getClassroom() {
        return classroom;
    }

    public int getCapacity() {
        return capacity;
    }

    public int getEnrolledCount() {
        return enrolledCount;
    }

    // Setter方法
    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public void setCredit(int credit) {
        this.credit = credit;
    }

    public void setTeacher(String teacher) {
        this.teacher = teacher;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public void setClassroom(String classroom) {
        this.classroom = classroom;
    }

    public void setCapacity(int capacity) {
        this.capacity = capacity;
    }

    // 选课人数增减方法
    public void incrementEnrolledCount() {
        if (enrolledCount < capacity) {
            enrolledCount++;
        }
    }

    public void decrementEnrolledCount() {
        if (enrolledCount > 0) {
            enrolledCount--;
        }
    }

    // toString方法
    @Override
    public String toString() {
        return "课程编号: " + courseId +
                ", 课程名称: " + courseName +
                ", 学分: " + credit +
                ", 教师: " + teacher +
                ", 时间: " + time +
                ", 教室: " + classroom +
                ", 容量: " + capacity +
                ", 当前选课人数: " + enrolledCount;
    }
}